import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
        /\.md$/, // .md
      ],
      imports: ["vue"], // 自动导入
      //这个一定要配置，会多出一个auto-import.d.ts文件，
      dts: './auto-import.d.ts'
    }),
    Components({
      resolvers: [ElementPlusResolver()],
      dirs: ['src/components','src/otherComponents','src/views'],
    }),
  ],
  resolve:{
    alias:{
      "@": resolve(__dirname, "./src"),
    }
  },
  server: {
		host: true,
		open: true,
    port:8000,
		proxy: {
		  '/api/': {
			target: '',
			changeOrigin: true,
			rewrite: (path) => path.replace(/^\/api/, ''),
		  },
		}
  }
})
